#218 refactor(examples): align hidden-information examples with priva…#230
Conversation
…s with privacy::stable FIXED
|
@Kappa16 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
salazarsebas
left a comment
There was a problem hiding this comment.
Review — request changes (CI + scope)
Solid direction on README depth and test coverage for hidden-information examples.
CI blocker
treasure_hunt fails at cargo fmt --check — import formatting in src/lib.rs (multiline vs single-line use).
Fix:
cd examples/treasure_hunt && cargo fmtScope gaps vs #218
battleshipandrock_paper_scissorswere modified but did not trigger CI in this PR. Please confirm both pass locally:cd examples/battleship && cargo test && stellar contract build cd examples/rock_paper_scissors && cargo test && stellar contract build
battleshipstill uses manualComponentTraitserialization. The issue called for migration toimpl_component!where applicable. Either complete that migration or document why manual serialization is retained.
Verdict
Merge after cargo fmt fix and confirmation that all four examples pass full validation.
I'll fix that as soon as possible |
|
PLEASE REVIEW |
|
PLEASE REVIEW @salazarsebas |
|
PLEASE REVIEW |
🔍 Findings (What Was Wrong)
cougr-core = "1.0.0"instead of"1.1.0"battleship/Cargo.toml,rock_paper_scissors/Cargo.toml,treasure_hunt/Cargo.toml,proof_of_hunt/Cargo.tomlBoardCommitmentin battleship implementedserialize()anddeserialize()by hand instead of using the standardizedimpl_component!macrobattleship/src/lib.rslines 34-53PlayerCommitmentin rock_paper_scissors implementedserialize()anddeserialize()by hand instead of usingimpl_component!rock_paper_scissors/src/lib.rslines 42-59treasure_huntimported fromcougr_core::zkinstead of the stableprivacy::stablesurfacetreasure_hunt/src/lib.rsline 3treasure_hunttest importedMerkleTreefromcougr_core::zkinstead ofprivacy::stabletreasure_hunt/src/test.rsline 2hidden_handreferencebattleship/src/test.rs,treasure_hunt/src/test.rs🛠️ Fixes Applied
Fix 1: Dependency Upgrade (4 files)
Applied to:
battleship/Cargo.toml,rock_paper_scissors/Cargo.toml,treasure_hunt/Cargo.toml,proof_of_hunt/Cargo.tomlFix 2: battleship — Replace Manual ComponentTrait with impl_component!
Fix 3: rock_paper_scissors — Replace Manual ComponentTrait with impl_component!
Note:
MatchStateretains manualComponentTraitbecause itsPhaseenum +Option<Address>fields don't map to the macro's fixed-size type system. This is documented in the README.Fix 4: treasure_hunt — Migrate Imports to privacy::stable
Fix 5: battleship — Add 3 New Tests
test_component_trait_via_macroimpl_component!(64 bytes output, correct component type)test_reveal_without_pending_attack"No pending attack"when revealing without prior attacktest_attack_before_commit"Not in attack phase"when attacking before boards are committedTotal battleship tests: 12 (was 10)
Fix 6: treasure_hunt — Add 3 New Tests
test_commit_phasetest_reveal_phase_with_valid_prooftest_invalid_reveal_value_rejectedTotal treasure_hunt tests: 12 (was 9)
Fix 7: All 4 READMEs — Complete Rewrite
Each README now includes these standardized sections:
Canonical(battleship) orTransitional(others) with version infohidden_handimpl_component!usagehidden_handand other related examples📊 Summary Matrix
impl_component!privacy::stableimpl_component!(partial)privacy::stable✅ Issue Requirements Checklist
cougr-core = "1.1.0"privacy::stableMerkle primitivesComponentTrait)impl_component!where applicableBoardCommitment), RPS (PlayerCommitment)hidden_handprivacy::stableSha256MerkleProofVerifieronlyCLOSE #218